<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
<title><?= $sf_response->getTitle() ?></title>
<?php use_helper('DateForm') ?>
<?php use_stylesheet('excelbutton') ?>
<?php use_stylesheet('/sf/sf_admin/css/main') ?>


<style type="text/css">
<!--
.style1 {
	font-size: 24px;
	font-weight: bold;
	color: #CC00CC;
}
.style2 {
	color: #0000FF;
	font-weight: bold;
}
-->
</style>

<div id="sf_admin_container">

<h1>Project report</h1>

<div id="sf_admin_content">
<?php echo form_tag('report/project', array(
  'id'        => 'sf_admin_edit_form',
  'name'      => 'sf_admin_edit_form',
  'multipart' => true,
)) ?>

<fieldset id="sf_fieldset_none" class="">

<div class="form-row">
  <label for="client_name" class="required">From Month:</label>  
  <div class="content">  
  <?php echo select_month_tag('filters[frommonth]', isset($filters['frommonth']) ? $filters['frommonth'] : 1) ?>
  <?php echo select_year_tag('filters[fromyear]', isset($filters['fromyear']) ? $filters['fromyear'] : null) ?>
    </div>
</div>

<div class="form-row">
  <label for="client_name" class="required">To Month:</label>  
  <div class="content">    
  <?php echo select_month_tag('filters[tomonth]', isset($filters['tomonth']) ? $filters['tomonth'] : null) ?>
  <?php echo select_year_tag('filters[toyear]', isset($filters['toyear']) ? $filters['toyear'] : null) ?>
  </div>
</div>

<div class="form-row">
  <label for="client_name" class="required">All projects:</label>  
  <div class="content">    
      <input type="checkbox" name="filters[allprojects]" id ="filters[allprojects]"   <?echo (isset($filters['allprojects'])) ? 'checked' : ''; ?>/>
  </div>
</div>    

<div class="form-row">
  <label for="client_name" class="required">Project:</label>  
  <div class="content">    
  
  <?php
   $c = new Criteria();
   $projectList = ProjectPeer::doSelect($c);
   if ($projectList){
   	echo '<select name="filters[projectId]" id="filters[projectId]">';
	   foreach ($projectList as $project){
	   		echo '<option ';
                        echo isset($filters['projectId']) && ($filters['projectId'] ==$project->getId())? ' selected="selected" ': '';
                        echo ' value="'.$project->getId().'" >'.$project->getName().'</option>';
	   }
	   echo '</select>';
   }
  ?>
  </div>
</div>
    
<div class="form-row">
  <label for="client_name" class="required">Type:</label>  
  <div class="content">    
      <select name="filters[type]" id="filters[type]">
          <option <? if (!isset($filters['type']) || $filters['type']==0) echo 'selected="selected" ';?> value="0">TALLY OUT TO PROJECT</option>
          <option <? if (isset($filters['type']) && $filters['type']==1) echo 'selected="selected" ';?>value="1">TALLY IN OF PROJECT</option>
          <option <? if (isset($filters['type']) && $filters['type']==2) echo 'selected="selected" ';?>value="2">PURCHASER ORDER OF PROJECT</option>
      </select>
  </div>
</div>




</fieldset>
<ul class="sf_admin_actions">
  <li><?php echo submit_tag(__('report'), array (
  'name' => 'report',
  'class' => 'sf_admin_action_save',
)) ?></li>
   <li><?php echo submit_tag(__('Export To Excel'), array (
  'name' => 'ExportToExcel',
  'class' => 'sf_admin_action_save',
)) ?></li>
  
</ul>

</form>

<?php if ( isset($result) && count($result) ){
	?>
<table width="100%" border="0" class="textalignright">
  <tr>
    <td><div align="center"><span class="style1">PROJECT REPORT</span></div></td>
  </tr>  
</table>
<strong><?echo $title?></strong>
<table width="100%" border="1" cellpadding="0" cellspacing="0" class="textalignright">
  <tr>
    <td><strong>NO</strong></td>
    <? 
    $keysRow = array_keys($result);
    $keysCol = array_keys($result[$keysRow[0]]);
    foreach ($keysCol as $key) 
    {
    ?>
        <td><strong><? echo $key?></strong></td>
    <?    
    }
    ?>
  </tr>
<? 
foreach ($keysRow as $row)
{
?>
  <tr>
    <td><?echo $row?></td>
    
    <? foreach ($keysCol as $col) 
    {
    ?>    
    <td><?
    if ($col == 'Qty')
        echo '<p align="right">';
    echo $result[$row][$col];
    ?></td>
    <?    
    }
    ?>
    
  </tr>
<?
}
?>
</table>
<?php }?>

</div>
</div>
